package com.etoak.common.core.vo;

import com.etoak.common.core.enums.ResultEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultVo<T> {
    private Integer code;
    private String msg;
    private T data;

    /**
     *默认执行之后调用{"code":200,"message":"执行成功","data":"null"}
     */
    public static <T> ResultVo<T> sussess() {
        return sussess(null);
    }

    public static <T> ResultVo<T> sussess(T data) {
        return new ResultVo<>(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(),data);
    }

    public static <T> ResultVo<T> filed(){
        return filed(ResultEnum.SYSTEM_ERROR);
    }

    public static <T> ResultVo<T> filed(ResultEnum resultEnum){
        return filed(resultEnum.getCode(),resultEnum.getMsg());
    }

    public static <T> ResultVo<T> filed(int code,String msg){
        return new ResultVo<>(code,msg,null);
    }
}
